unit scCodeItem;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, sBitBtn, DB, Mask, DBCtrls, sDBEdit,
  sDBLookupComboBox, ExtCtrls, sBevel;

type
  TfmCodeItem = class(TForm)
    edtName: TsDBEdit;
    dsCode: TDataSource;
    edtCode: TsDBEdit;
    edtShortName: TsDBEdit;
    sbtbtnOk: TsBitBtn;
    sbtbtnCacel: TsBitBtn;
    dsCodeParentSelect: TDataSource;
    cbbCodeParentSelect: TsDBLookupComboBox;
    sbvl1: TsBevel;
    edtOrder: TsDBEdit;
    procedure cbbCodeParentSelectKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure edtNameExit(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

implementation

uses dbMyUtils;

{$R *.dfm}

procedure TfmCodeItem.cbbCodeParentSelectKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  if Key = VK_DELETE then
  begin
    cbbCodeParentSelect.KeyValue := null;
  end;

end;

procedure TfmCodeItem.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  if Self.ModalResult = mrOK  then
  try
    PostChanges(dsCode.DataSet);
  except
    Action := caNone;
  end;
end;

procedure TfmCodeItem.edtNameExit(Sender: TObject);
begin
  if (Length(edtName.Field.AsString) > 0) and (Length(edtName.Field.AsString) < 65) then
    if edtShortName.Field.IsNull then
      edtShortName.Field.AsString := edtName.Field.AsString;
end;

end.
